package com.lay.http;

import android.annotation.SuppressLint;
import android.support.v4.app.Fragment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RequestFragment extends Fragment {
    public static final String FOR_HTTP = "FOR_HTTP";
    Map<Long, LifeRecycle> lifeRecycleList = new HashMap<>();

    public void registeLifeRecycle(long time, LifeRecycle lifeRecycle){
        if(lifeRecycle == null){
            throw new IllegalArgumentException("lifeRecycle == null");
        }
        lifeRecycleList.put(time, lifeRecycle);
    }

    public void unregisteLifeRecycle(long time){
        lifeRecycleList.remove(time);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        for(Map.Entry<Long, LifeRecycle> entry : lifeRecycleList.entrySet()) {
            entry.getValue().onDestroy();
        }
    }
}
